/**
 * 许可证状态获取接口测试用例
 *
 * Created by raquelmao on 2020/08/14.
 */
const chai = require('chai');
const should = chai.should(); // eslint-disable-line no-unused-vars
chai.use(require('chai-http'));

const common = require('./../common');
const Administrator = require('./../../models/administrator');
const uri = require('./uri');

module.exports = describe('/GET machine/compilation-options.json', function () {
  const administrator = new Administrator();
  const url = '/machine/compilation-options.json';
  const newUserIds = [];
  let tester;

  before(function (done) {
    administrator.createRandomTester()
      .then((res) => {
        tester = res;
        newUserIds.push(tester.userId);
        done();
      })
      .catch(done);
  });
  after(function (done) {
    administrator.removeUsers(newUserIds)
      .then(() => {
        done();
      })
      .catch(done);
  });

  common.should.be.user(uri, url, 'get');
  common.should.be.tester(uri, url, 'get');

  // 正常请求
  it('it should GET compilation options', function (done) {
    tester.login()
      .then(() => {
        chai.request(uri)
          .get(url)
          .set('Authorization', `Bearer ${tester.token.accessToken}`)
          .end((err, res) => {
            res.should.have.status(200);
            common.should.be.compilationOptionsMessage(res.body);
            done();
          });
      })
      .catch(done);
  });
});
